package com.eckey.lab.config;

import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AbstractFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: Marinc
 * @CreateTime: 2023-06-26  22:41
 * @Description: TODO
 * @Version: 1.0
 */
@Slf4j
@Configuration
public class ESConfigBean {

    @Autowired
    private ESProperties esProperties;

    @Bean
    public RestHighLevelClient restClient() {
        RestHighLevelClient restHighLevelClient = new RestHighLevelClient(RestClient.builder(
                HttpHost.create(esProperties.getHost())
        ));
        return restHighLevelClient;
    }
}

